package com.insurance.modules.claim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.insurance.common.utils.PageUtils;
import com.insurance.common.utils.Query;
import com.insurance.modules.claim.dao.ContactRecordDao;
import com.insurance.modules.claim.entity.ContactRecordEntity;
import com.insurance.modules.claim.service.ContactRecordService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("contactRecordService")
public class ContactRecordServiceImpl extends ServiceImpl<ContactRecordDao, ContactRecordEntity> implements ContactRecordService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ContactRecordEntity> page = this.page(
                new Query<ContactRecordEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    public Page<ContactRecordEntity> pageList(Page<ContactRecordEntity> page, String csId) {
        LambdaQueryWrapper<ContactRecordEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ContactRecordEntity::getCsId, csId)
                .orderByDesc(ContactRecordEntity::getContactTime);
        return getBaseMapper().selectPage(page, wrapper);
    }

}